import request from '@/utils/request'

// 创建工单
export function createWorkOrder(data) {
  return request({
    url: '/production/work-order/create',
    method: 'post',
    data: data
  })
}

// 更新工单
export function updateWorkOrder(data) {
  return request({
    url: '/production/work-order/update',
    method: 'put',
    data: data
  })
}

// 删除工单
export function deleteWorkOrder(id) {
  return request({
    url: '/production/work-order/delete?id=' + id,
    method: 'delete'
  })
}

/** 批量删除工单 */
export function deleteWorkOrderList(ids) {
  return request({
    url: `/production/work-order/delete-list?ids=${ids.join(',')}`,
    method: 'delete'
  })
}

// 获得工单
export function getWorkOrder(id) {
  return request({
    url: '/production/work-order/get?id=' + id,
    method: 'get'
  })
}

// 获得工单分页
export function getWorkOrderPage(params) {
  return request({
    url: '/production/work-order/page',
    method: 'get',
    params
  })
}
// 导出工单 Excel
export function exportWorkOrderExcel(params) {
  return request({
    url: '/production/work-order/export-excel',
    method: 'get',
    params,
    responseType: 'blob'
  })
}

// 开工、下发
export function issued(id) {
  return request({
    url: '/production/work-order/issued?id=' + id,
    method: 'post'
  })
}

// 暂停继续
export function paused(id) {
  return request({
    url: '/production/work-order/paused?id=' + id,
    method: 'post'
  })
}

export function finish(id) {
  return request({
    url: '/production/work-order/finish?id=' + id,
    method: 'post'
  })
}

